package com.achievo.know.web.auth;

import javax.servlet.http.HttpSession;
import javax.servlet.http.HttpSessionEvent;
import javax.servlet.http.HttpSessionListener;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.ServletActionContext;

import com.achievo.know.application.CodeDictCacheHandler;

public class SessionListen implements HttpSessionListener {

	@Override
	public void sessionCreated(HttpSessionEvent se) {

	}

	@Override
	public void sessionDestroyed(HttpSessionEvent se) {
		HttpSession session = se.getSession();
		String loginuser=(String) session.getAttribute("loginuser");
		if(StringUtils.isNotEmpty(loginuser)){
			CodeDictCacheHandler.removeObject(loginuser);
			//CodeDictCacheHandler.removeObject(loginuser+"_session");
			ServletActionContext.getContext().getApplication().remove(loginuser+"_session");
			//CodeDictCacheHandler.removeObject(loginuser+"_auths");
			//CodeDictCacheHandler.removeObject(loginuser+"_cateIds");
			//CodeDictCacheHandler.removeObject(loginuser+"_adminCateIds");
		}
	}

}
